<script setup lang="ts">
import {ref} from "vue";


const difficulty = ref(undefined)
const keyword = ref('')

const emit = defineEmits(['search'])

function search() {
  keyword.value = keyword.value.trim()
  emit('search', difficulty.value, keyword.value)
}

function reset() {
  difficulty.value = undefined
  keyword.value = ''
  emit('search', difficulty.value, keyword.value)
}

</script>

<template>
  <div class="container">
    <!--    题目难度选择-->
    <el-select v-model="difficulty" placeholder="选择难度" style="width: 200px;">
      <el-option label="简单" value="1"/>
      <el-option label="中等" value="2"/>
      <el-option label="困难" value="3"/>
    </el-select>
    <el-input v-model="keyword" placeholder="搜索题目、内容" style="width: 400px; margin-left: 10px;"/>
    <el-button type="primary" @click="search" style="margin-left: 10px;">搜索</el-button>
    <el-button @click="reset" style="margin-left: 10px;">重置</el-button>
  </div>
</template>

<style scoped lang="scss">
.container {
  display: flex;
  align-items: center;
  padding: 10px;
  //background-color: #f9f9f9;
  border-radius: 8px;
}
</style>